{
    // class User{
    //     name: string = 'abc'
    //     constructor(name: string){
    //         this.name = name;
    //     }
    // }

    // 简写,加上修饰符
    // class User{
    //     constructor(public name: string){}
    // }

    class User{
        constructor(public name: string){
            this.name = this.initName(name);        //constructor中也可以调用方法
        }

        private initName(name: string){
            return name;
        }
    }

    const user = new User('hdms');
    console.log(user.name);
}